﻿//-----------------------------------------------------------------------
// <copyright file="MLTraceListener.cs" company="MAPILab Ltd">
//     Copyright (c) MAPILab Ltd.  All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace MAPILab.SharePoint.Explorer.CodeForm
{
    using System.Diagnostics;

    /// <summary>
    /// Trace listner to debug code from code form
    /// </summary>
    public class MLTraceListener : TraceListener
    {
        #region Fields

        /// <summary>
        /// Target of trace messages for MLTraceListener
        /// </summary>
        private MLCodeForm codeForm;

        #endregion

        #region Property
        /// <summary>
        /// Get and set code form property
        /// </summary>
        public MLCodeForm CodeForm
        {
            get { return codeForm; }
            set { codeForm = value; }
        }

        #endregion

        #region Overridden methods

        /// <summary>
        /// Write trace message in codeform
        /// </summary>
        /// <param name="message"></param>
        public override void Write(string message)
        {
            codeForm.Write(message);
        }

        /// <summary>
        /// Write trace message in codeform in separate line
        /// </summary>
        /// <param name="message"></param>
        public override void WriteLine(string message)
        {
            codeForm.WriteLine(message);
        }

        #endregion
    }
}
